/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc.convert;

import cn.yzc.pojo.Point;
import org.springframework.core.convert.converter.Converter;

import java.awt.*;

/**
 * <p>Project: SpringMVCPro - PointConvert</p>
 * <p>Powered by yzc On 2023-10-31 14:15:25</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */

/**
 * 类型转换器
 */
public class PointConvert implements Converter<String, Point> {

    @Override
    public Point convert(String source) {
        if(source == null || "".equals(source))
            return null;
        String []gdt =source.split(",");
        if (gdt.length != 2)
            return null;
        Point point =new Point();
        point.setX(Integer.parseInt(gdt[0]));
        point.setY(Integer.parseInt(gdt[1]));
        return point;
    }
}
